cmake_minimum_required(VERSION 3.5 FATAL_ERROR)

project(recipe-03 LANGUAGES CXX)

add_library(message-objs OBJECT Message.hpp Message.cpp)                    # OBJECT的用法

set_target_properties(message-objs PROPERTIES POSITION_INDEPENDENT_CODE 1)

add_library(message-shared SHARED $<TARGET_OBJECTS:message-objs>)           # $<TARGET_OBJECTS:message-objs> 引用对象库的生成器表达式
set_target_properties(message-shared PROPERTIES OUTPUT_NAME message)        # 更改输出名字

add_library(message_static STATIC $<TARGET_OBJECTS:message-objs>)           # $<TARGET_OBJECTS:message-objs> 引用对象库的生成器表达式
set_target_properties(message_static PROPERTIES OUTPUT_NAME message)        # 更改输出名字

add_executable(hello-world hello-world.cpp)
target_link_libraries(hello-world message-static)

